var gulp = require('gulp'),
	less = require('gulp-less'),
	concat = require('gulp-concat'),
	minifycss = require('gulp-minify-css'),
	rename = require('gulp-rename'),
	uglify = require('gulp-uglify'),
	del = require('del');

gulp.task('less', function(cb) {
	gulp.src('less/zui.less')
		.pipe(less())
		.pipe(gulp.dest('dist/css'))
		.pipe(rename({
			suffix: '.min'
		}))
		.pipe(minifycss())
		.pipe(gulp.dest('dist/css'));
	gulp.src('less/sb-admin-2.less')
		.pipe(less())
		.pipe(gulp.dest('dist/css'))
		.pipe(rename({
			suffix: '.min'
		}))
		.pipe(minifycss())
		.pipe(gulp.dest('dist/css'));
});

gulp.task("zip", function() {
	gulp.src('js/sb.*')
		.pipe(concat('zui.js'))
		.pipe(gulp.dest('dist/js'))
		.pipe(rename({
			suffix: '.min'
		}))
		.pipe(uglify())
		.pipe(gulp.dest('dist/js'));

	gulp.src('js/sb-admin-2.js')
		.pipe(rename({
			suffix: '.min'
		}))
		.pipe(uglify())
		.pipe(gulp.dest('dist/js'));
})

gulp.task('default', [
	'less'
]);

gulp.task('watch', function() {
	gulp.watch('less/*.less', ['less']);
	gulp.watch('js/sb*', ['zip']);
});